// NewWindowDlg.cpp : implementation file
//

#include "stdafx.h"
#include "NewWindowDlg.h"
#include <mshtml.h>
#include <atlbase.h>
#include <afxpriv2.h>
#include <afxconv.h>
#include <wincrypt.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define  ID_BUTTON_REFRESH 101

/////////////////////////////////////////////////////////////////////////////
// CNewWindowDlg dialog

int CNewWindowDlg::ms_nTopSize = 23;
int CNewWindowDlg::ms_nLeftSize = 2;
int CNewWindowDlg::ms_nRightSize = 2;
int CNewWindowDlg::ms_nBottomSize = 2;

CNewWindowDlg::CNewWindowDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CNewWindowDlg::IDD, pParent)
{
	m_bMaximum = FALSE;
}


void CNewWindowDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CNewWindowDlg, CDialog)
	//{{AFX_MSG_MAP(CNewWindowDlg)
	ON_WM_SIZE()
	ON_WM_CREATE()
	ON_WM_CLOSE()
	ON_WM_ERASEBKGND()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
	ON_WM_NCCALCSIZE()
	ON_WM_NCPAINT()
	ON_WM_NCHITTEST()
	ON_WM_SIZING()
	ON_WM_NCLBUTTONDOWN()
	ON_WM_NCMBUTTONDBLCLK()
	ON_WM_NCLBUTTONDBLCLK()
END_MESSAGE_MAP()


BOOL CNewWindowDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog

	SetClassLong(m_hWnd,GCL_STYLE,CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS);
	

	this->BringWindowToTop();
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CNewWindowDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
}

LRESULT CNewWindowDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	LRESULT lResult = CDialog::DefWindowProc(message, wParam, lParam);
	return lResult;
}

int CNewWindowDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	return 0;
}

void CNewWindowDlg::OnClose() 
{

	CDialog::OnClose();
}

BEGIN_EVENTSINK_MAP(CNewWindowDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CNewWindowDlg)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()


BOOL CNewWindowDlg::OnEraseBkgnd(CDC *pDC)
{	
	return TRUE;
}

void CNewWindowDlg::OnPaint() 
{
	CDialog::OnPaint();
}

void CNewWindowDlg::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
	CDialog::OnNcCalcSize(bCalcValidRects, lpncsp);
}

void DrawNCRegion( CWnd* pWnd, UINT nIDResource, const CRect& rc )
{
	CDC MemoryDC;
	CDC* pDC = pWnd->GetWindowDC();
	MemoryDC.CreateCompatibleDC(pDC);

	CBitmap NcBitmap;
	NcBitmap.LoadBitmap( nIDResource );
	BITMAP* pBitMap = new BITMAP();
	NcBitmap.GetBitmap( pBitMap );
	MemoryDC.SelectObject( NcBitmap );
	MemoryDC.SelectObject( NcBitmap );
	pDC->StretchBlt( rc.left, rc.top, rc.Width(), rc.Height(), &MemoryDC, 0, 0, pBitMap->bmWidth, pBitMap->bmHeight, SRCCOPY); 

	MemoryDC.DeleteDC(); 
	pWnd->ReleaseDC( pDC ); 
	delete pBitMap;
}

void CNewWindowDlg::OnNcPaint()
{
	CDialog::OnNcPaint();

}

LRESULT CNewWindowDlg::OnNcHitTest(CPoint point)
{
	return CDialog::OnNcHitTest(point); 
}

void CNewWindowDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
	CDialog::OnSizing(fwSide, pRect);
}

void CNewWindowDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
	CDialog::OnNcLButtonDown(nHitTest, point);
}

void CNewWindowDlg::OnNcMButtonDblClk(UINT nHitTest, CPoint point)
{
	CDialog::OnNcMButtonDblClk(nHitTest, point);
}

void CNewWindowDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
{
	CDialog::OnNcLButtonDblClk(nHitTest, point);
}
